﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Management;
using System.IO;

namespace EzDeploy
{
	public class Tools
	{
		public Tools()
		{
			// Insert code required on object creation below this point.
		}
		
		public static string Detect3264()
		{
			ConnectionOptions oConn = new ConnectionOptions();
			System.Management.ManagementScope oMs = new System.Management.ManagementScope("\\\\localhost", oConn);
			System.Management.ObjectQuery oQuery = new System.Management.ObjectQuery("select AddressWidth from Win32_Processor");
			ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs, oQuery);
			ManagementObjectCollection oReturnCollection = oSearcher.Get();
			string addressWidth = null;

			foreach (ManagementObject oReturn in oReturnCollection)
			{
				addressWidth = oReturn["AddressWidth"].ToString();
			}

			return addressWidth;
		}

        public static BitmapImage ConvertFromStreamToBitmapImage(object value)
        {
            BitmapImage image = new BitmapImage();

            try
            {
                if (value != null)
                {
                    image.BeginInit();
                    image.StreamSource = value as Stream;
                    image.EndInit();
                }
            }
            catch
            {
                image = FileTypeToIconConverter.imageApp;
            }

            return image;
        }
	}

    public class LeftMarginConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            double sliderValue = (double)value;
            return new Thickness(sliderValue, 0, 0, 0);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        #endregion
    }
}